<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="content">
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form id="userView" prependId="false">
                <p:panel header="Unquoted quotations from Vendors" style="text-align: center">
<!--                    <p:outputPanel id="book"> -->
                        <p:dataTable  value="#{rawMaterialQuotationController.rmqs}" var="rmq" 
                                      paginator="true" rows="10"  
                                      paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
                                      >     
                            <p:column sortBy="#{rmq.rawMaterial.productName}" filterBy="#{rmq.rawMaterial.productName}">   
                                <f:facet name="header">  
                                    <h:outputText value="Raw Material Name" />
                                </f:facet>
                                <h:outputText value="#{rmq.rawMaterial.productName}" /> </p:column>

                            <p:column sortBy="#{rmq.vendor.companyName}" filterBy="#{rmq.vendor.companyName}">    <f:facet name="header">  
                                    <h:outputText value="Vendor Name" /> </f:facet>
                                <h:outputText value="#{rmq.vendor.companyName}" /> </p:column>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Valid until:"/>
                                </f:facet>
                                <h:outputText value="#{rmq.validity}">
                                    <f:convertDateTime pattern="dd/MM/yyyy" />
                                </h:outputText>
                            </p:column>  

                            <p:column>
                                <p:menuButton value="Options">  

                                    <p:menuitem value="Update" ajax="false" icon="ui-icon ui-icon-disk" 
                                                action="EditQuotation" >
                                        <f:setPropertyActionListener value="#{rmq}"  
                                                                     target="#{rawMaterialQuotationController.currRawMaterialQuotation}" />
                                    </p:menuitem>
                                    <p:menuitem value=" Remove" ajax="false" icon="ui-icon ui-icon-disk" 
                                                action ="#{rawMaterialQuotationController.delete1}">
                                        <f:setPropertyActionListener value="#{rmq}"  
                                                                     target="#{rawMaterialQuotationController.selectedQuota}" />

                                    </p:menuitem> 

                                </p:menuButton>
                            </p:column>
                        </p:dataTable> 
<!--                    </p:outputPanel>-->
                </p:panel>
             
                <p:separator/>

                <p:panel header="Quoted quotations from Vendors" style="text-align: center">
                    <p:outputPanel id="books"> 
                        <p:dataTable  value="#{rawMaterialQuotationController.rmqqs}" var="rmq" 
                                      paginator="true" rows="10"  
                                      paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
                                      >     
                            <p:column sortBy="#{rmq.rawMaterial.productName}" filterBy="#{rmq.rawMaterial.productName}">    <f:facet name="header">  
                                    <h:outputText value="Raw Material Name" /> </f:facet>
                                <h:outputText value="#{rmq.rawMaterial.productName}" /> </p:column>

                            <p:column sortBy="#{rmq.vendor.companyName}" filterBy="#{rmq.vendor.companyName}">    <f:facet name="header">  
                                    <h:outputText value="Vendor Name" /> </f:facet>
                                <h:outputText value="#{rmq.vendor.companyName}" /> </p:column>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Valid until:"/>
                                </f:facet>
                                <h:outputText value="#{rmq.validity}">
                                    <f:convertDateTime pattern="dd/MM/yyyy" />
                                </h:outputText>
                            </p:column>  
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="&nbsp;"/>
                                </f:facet>
                                <p:commandButton image="ui-icon ui-icon-search" update="display" oncomplete="customerDialog.show()">
                                    <f:setPropertyActionListener value="#{rmq}"  
                                                                 target="#{rawMaterialQuotationController.selectedQuota}" /> 
                                </p:commandButton>
                            </p:column>
                            <p:column>  
                                <f:facet name="header">  
                                    <h:outputText value="Operations" />  
                                </f:facet>  
                                <p:commandButton value="Remove"  ajax="false"  action ="#{rawMaterialQuotationController.delete}" >
                                    <f:setPropertyActionListener value="#{rmq}"  
                                                                 target="#{rawMaterialQuotationController.selectedQuota}" /> 

                                </p:commandButton>  
                            </p:column>  
                        </p:dataTable> 
                    </p:outputPanel> 
                </p:panel>
                <br/>
   <br/>
                <p:commandButton  value="Delete Past Unquoted Quotations" oncomplete="dialog.show()" />
                <p:dialog header="Quotation Information:" widgetVar="customerDialog" resizable="false"  
                          width="325" showEffect="explode" hideEffect="explode">  

                    <h:panelGrid id="display" columns="2" cellpadding="4">  
                        <h:outputText value="Vendor:"/>
                        <h:outputText value="#{rawMaterialQuotationController.selectedQuota.vendor.companyName}"/>

                        <h:outputText value="Product:"/>
                        <h:outputText value="#{rawMaterialQuotationController.selectedQuota.rawMaterial.productName}"/>     
                        <h:outputText value="Price:"/>
                        <h:outputText value="#{rawMaterialQuotationController.selectedQuota.price}"/>
                        <h:outputText value="Quantity:"/>
                        <h:outputText value="#{rawMaterialQuotationController.selectedQuota.quantity}"/>
                        <h:outputText value="Total cost:"/>
                        <h:outputText value="#{rawMaterialQuotationController.selectedQuota.cost}"/>
                        <h:outputText value="Vendor Note:"/>
                        <h:outputText value="#{rawMaterialQuotationController.selectedQuota.note}"/>
                    </h:panelGrid>  
                </p:dialog>  
                <p:dialog header="Manage Past Unquoted Quotations :" widgetVar="dialog" resizable="false"  
                          width="700" height="300" modal="true" showEffect="explode" hideEffect="explode">  

                    <h:outputText value="Delete Past Unquoted Quotations that has validity past:"/>
                    &nbsp;
                    <p:calendar value="#{rawMaterialQuotationController.lastDate}"  mode ="inline"/>               

                    <p:commandButton ajax="false" value="Confirm" action ="#{rawMaterialQuotationController.invalidQuotation}" update ="panel,books,growl" />
                </p:dialog> 

            </h:form>
        </ui:define>
    </ui:composition>

</html>